home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / Ivy 1.0fc1 / Ivy.vulib < prev   
Encoding:
Text File  |  1993-08-13  |  6.9 KB  |  278 lines  |  [TEXT/MPS ]

  1. #
  2. #    IMPORTANT: Although you can call the Ivy tool services directly from your script, please use
  3. #    the Ivy "high-level" task library we've provided.  Doing so, will ensure compatibility with
  4. #    future versions of Ivy.
  5. #
  6. #    For more COMPLETE DOCUMENTATION on the Ivy task library see the document titled
  7. #    'Ivy Task Library documentation.'
  8. #
  9.  
  10. tool Ivy signature:'IVYX'
  11.  
  12. #
  13. # NOTE : Data types listed as 'symbol' are actually Boolean -the Virtual User does not explicitly
  14. #                 support the Boolean type.
  15.     
  16. begin
  17.  
  18. #    SERVICES TO SET THE CURRENT DIRECTORY AND DELETE FILES
  19.     
  20.     Service "IVSetDirectory"( 'String' ) return 'String';
  21.     
  22.     Service "IVGetDirectory"() return 'String';
  23.     
  24.     Service "IVDeleteImage"( 'String', 'String' ) return 'Symbol';
  25.     
  26. # SERVICES TO CALCULATE SCREEN IMAGE CHECKSUMS
  27.     
  28.     Service "IVSetChecksumMode"( 'Symbol' ) return 'Symbol';
  29.  
  30.     Service "IVChecksumImage"(    'List' ) return 'String';
  31.     
  32. # SERVICES TO CAPTURE AND COMPARE 'PICT' SCREEN IMAGAES
  33.     
  34.     Service "IVCreateImage"( 'String', 'String', 'List', 'Symbol', 'List' ) return 'Symbol';
  35.     
  36.     Service "IVCompareImages"(    'String', 'String',
  37.                                      'String', 'String',
  38.                                      'String', 'String', 'List') return 'Symbol';
  39.                                     
  40.     Service    "IVGetImageInfo"( 'String', 'String' ) return 'list';
  41.     
  42. # SERVICES COMMON TO ALL VIRTUAL USER 2.0 EXTERNAL TOOLS
  43.     
  44.     Service "Initialize"( 'Undefined' );
  45.     
  46.     Service "Cancel"( 'String' );
  47.     
  48.     Service "GetToolServices"() return 'List';
  49.     
  50.     Service "GetToolVersion"() return 'List';
  51.     
  52.     Service "Poll"( 'String' ) return 'String';
  53.     
  54.     Service "ServiceSupported"( 'String' ) return 'Undefined';
  55.     
  56.     Service "Quit"();
  57.     
  58. end;
  59.  
  60.  
  61. #--------------------------------------------------------------------------------------------------
  62.  
  63.  
  64. #    ÏÏÏ        INITIALIZATION TASKS
  65.  
  66.  
  67. task IVInit( location ) 
  68. #
  69. # Use this task to initialize the Ivy external tool.  NOTE: You must call this task before using
  70. # any other Ivy tasks!
  71. #
  72. # This task also sets the image information globals(constants). Use these globals to index the
  73. # list of values returned by the 'IVGetImageInfo' task.
  74. #
  75. begin
  76.     global kImageFrame := 1;
  77.     global kIvyVersion := 2;
  78.     global kImageSize    := 3;
  79.     global kImageBitMapChecksum := 4;
  80.     global kImageRGBChecksum := 5;
  81.     global kImagePixelCount := 6;
  82.     global kImageBitDepth := 7;
  83.     global kImageTimeStamp := 8;
  84.     global kImageDateStamp := 9;
  85.  
  86.     result := Ivy("Initialize", location);  # true launches on the target, false on the host.
  87.     
  88.     return result;
  89. end;
  90.  
  91.  
  92. task IVQuit( )
  93. #
  94. # Use this task to quit Ivy.
  95. #
  96. begin
  97.     return Ivy( "Quit" );
  98. end;
  99.  
  100.  
  101. #    TASKS TO SET THE CURRENT DIRECTORY AND DELETE FILES
  102.  
  103.  
  104. task IVSetDirectory( pathName ) # return pathName
  105. #
  106. #     This task sets Ivy's default file directory.  Ivy will place all the images it
  107. #     creates into the default directory; assuming, of course, you did NOT supply a full or partial
  108. #        pathname.
  109. #
  110. begin
  111.     result := Ivy( "IVSetDirectory", pathName );
  112.     
  113.     return result;
  114. end;
  115.  
  116.  
  117. task IVGetDirectory( ) # return pathName
  118. #
  119. #    This task returns a string describing the full pathname of Ivy's default directory.
  120. #    See the above description of the task 'IVSetDirectory.'
  121. #
  122. begin
  123.     result := Ivy( "IVGetDirectory" );
  124.     
  125.     if ( result[1] <> 0 )
  126.         println "### IVGetDirectory - ", result;
  127.         
  128.     return result;
  129. end;
  130.  
  131.  
  132. task IVDeleteImageFile( imageName ) # return boolean
  133. #    
  134. #    This task deletes the file with the name 'imageName' from Ivy's default directory.
  135. #
  136. begin
  137.     result := Ivy( "IVDeleteImage", imageName, '' );
  138.     
  139.     if ( result[1] <> -43 and result[1] <> 0 )
  140.         println "### IVDeleteImageFile - ", result;
  141.         
  142.     return result;
  143. end;
  144.  
  145.  
  146. # TASKS TO CAPTURE AND COMPARE 'PICT' SCREEN IMAGAES
  147.  
  148.  
  149. task IVCreateImageFile( imageName, imageRectangle, ignoreRectangles := { } ) # return boolean
  150. #
  151. #    This task creates an Ivy image file.  The file will contain the screen image enclosed
  152. #    by the 'imageRectangle' parameter.  You must specify the 'imageRectangle parameter in
  153. #    global coordinates.
  154. #
  155. begin
  156.     kDupFNErr := -48;
  157.     
  158.     result := Ivy( "IVCreateImage", imageName, imageName, imageRectangle, true, ignoreRectangles );
  159.         
  160.     if ( result[1] = kDupFNErr or result[1] = -1 )
  161.     begin
  162.             Ivy( "IVDeleteImage", imageName, '' );
  163.             result := Ivy( "IVCreateImage", imageName, imageName, imageRectangle, true, ignoreRectangles );
  164.     end;
  165.  
  166.     if ( result[1] <> 0 )
  167.         println "### IVCreateImageFile - ", result;
  168.         
  169.     return result;
  170. end;
  171.  
  172.  
  173. task IVCreateTempImage ( tTempName, imageRectangle )
  174. #
  175. # This task is NOT supported, so please do not use it!
  176. #
  177. begin
  178.     tFileName := tTempName;
  179.     tTempName := tTempName + NumToStr( random( 1, 32767 ), 16 );
  180.     kDupFNErr := -48;
  181.  
  182.     result := IVCreateImageFile( tTempName, imageRectangle );
  183.     while ( result[1] = kDupFNErr )
  184.         begin
  185.             tTempName := tFileName + NumToStr( random(1, 32767 ), 16 );
  186.             result := IVCreateImageFile( tTempName, imageRectangle );
  187.         end;
  188.         
  189.     if ( result[1] <> 0 )
  190.         println "### IVCreateTempImage - ", result;
  191.     else
  192.         result := result + { tTempName };
  193.         
  194.     return result;
  195. end;
  196.  
  197.  
  198. task IVCompareImageFiles( firstImage, secondImage, resultImage, ignoreRectangles := { } ) # return boolean
  199. #
  200. #    This task compares two images and hilites any differences in a new image.
  201. #    See above for a description of the 'ignoreRectangles' parameter.  The 'resultImage'
  202. #    parameter is optional; if the task caller supplies it, the task will create a new image
  203. #    hiliting the differences between the two source images.
  204. #
  205. begin
  206.     result := Ivy( "IVCompareImages",    firstImage, firstImage, 
  207.                                         secondImage, secondImage, 
  208.                                         resultImage, resultImage, ignoreRectangles );
  209.     
  210.     if ( result[1] <> 0 )
  211.         println "### IVCompareImageFiles - ", result;
  212.         
  213.     return result;
  214. end;
  215.  
  216.  
  217. task IVGetImageInfo( imageFile, imageName := '' ) # return a list of values
  218. #
  219. #    This task returns the following list of values: a rectangle, the bit depth of the image,
  220. #    the size of the image in bytes, the unsigned 32 bit checksum of the image, and the
  221. #    date the image was created.
  222. #
  223. begin
  224.     result := Ivy( "IVGetImageInfo", imageFile, imageName );
  225.     
  226.     if ( result[1] <> 0 )
  227.         println "### IVGetImageInfo - ", result;
  228.         
  229.     return result;
  230. end;
  231.  
  232.  
  233. # TASKS TO CALCULATE SCREEN IMAGE CHECKSUMS
  234.  
  235.  
  236. task IVSetChecksumMode( RGBFlag )
  237. begin
  238.     result := Ivy( "IVSetChecksumMode", RGBFlag );
  239.     
  240.     if ( result[1] <> 0 )
  241.         println "### IVSetChecksumMode - ", result;
  242.         
  243.     return result;
  244. end;
  245.  
  246.  
  247. task IVChecksumRectangle( imageRectangle ) # return a string representing a 32 bit unsigned integer
  248. #
  249. #    This task performs a simple checksum on an image.
  250. #
  251. begin
  252.     result := Ivy( "IVChecksumImage", imageRectangle );
  253.     
  254.     if ( result[1] <> 0 )
  255.         println "### IVChecksumRectangle - ", result;
  256.         
  257.     return result;
  258. end;
  259.  
  260.  
  261. task IVCreateChecksumFile( imageName, imageRectangle ) # return a string representing a 32 bit unsigned integer
  262. #
  263. #    This task creates a new file named imageName and stores the 32 bit checksum value in the
  264. #    resource fork of the file; in a type 'IVYC' resource.
  265. #
  266. begin
  267.     result := Ivy( "IVCreateImage", imageName, imageName, imageRectangle, false, {} );
  268.     
  269.     if ( result[1] <> 0 )
  270.         println "### IVCreateChecksumFile - ", result;
  271.         
  272.     return result;
  273. end;
  274.  
  275.  
  276.  
  277.  
  278.